package com.questionnaire.core.shiro.custom;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;

/**
 * 重写HashedCredentialsMatcher类中的doCredentialsMatch()
 */
public class MyRetryLimitCredentialsMatcher extends HashedCredentialsMatcher {
    @Override
    public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
        CustomUsernamePwdToken tk = (CustomUsernamePwdToken) authcToken;
        if(tk.getType().equals(LoginType.NOPASSWD)){// 免密登录
            return true;
        }
        boolean matches = super.doCredentialsMatch(authcToken, info);
        return matches;
    }
}
